<template>
<onekit-page>
<onekit-view onekit-class="container">
	<div is="onekit-template-head" :DATA="`${JSON.stringify({title:'getLocation'})}`"></div>
	<onekit-view onekit-class="page-body">
		<onekit-view onekit-class="page-section">
			<onekit-view onekit-class="page-body-info">
				<onekit-text onekit-class="page-body-text-small">当前位置经纬度</onekit-text>
				<template v-if="hasLocation == false">
					<onekit-text onekit-class="page-body-text">未获取</onekit-text>
				</template>
				<template v-if="hasLocation == true">
					<onekit-view onekit-class="page-body-text-location">
						<onekit-text>E: {{location.longitude[0]}}°{{location.longitude[1]}}′</onekit-text>
						<onekit-text>N: {{location.latitude[0]}}°{{location.latitude[1]}}′</onekit-text>
					</onekit-view>
				</template>
			</onekit-view>
			<onekit-view onekit-class="btn-area">
				<onekit-button type="primary" @Tap="getLocation">获取位置</onekit-button>
				<onekit-button @Tap="clear">清空</onekit-button>
			</onekit-view>
		</onekit-view>
	</onekit-view>
	<div is="onekit-template-foot"></div>
</onekit-view>
</onekit-page></template>
<script>
/* eslint-disable */
import Vue from 'vue';
import onekit_template_0 from '../../../common/head.head.vue';Vue.component('onekit-template-head',onekit_template_0);
import onekit_template_1 from '../../../common/foot.foot.vue';Vue.component('onekit-template-foot',onekit_template_1);
const ONEKIT_JSON= {
  "navigationBarTitleText": "获取位置",
  "usingComponents": {
    
  }
};
const ONEKIT_SJS = {
};
import wx from '../../../../weixin2vue/wx.js';
import Macro from '../../../../weixin2vue/Macro.js';
const {getApp,getCurrentPages} = Macro;
import Page from '../../../../weixin2vue/OnekitPage.js';
import Component from '../../../../weixin2vue/OnekitComponent.js';
const util = require('../../../util/util.js');
const formatLocation = util.formatLocation;
export default Page(ONEKIT_JSON,["hasLocation","E: ","location","longitude","°","′","N: ","latitude"],ONEKIT_SJS,{
    "onShareAppMessage"(){
      return {
        "title":'获取位置',
        "path":'packageAPI/pages/get-location/get-location'
};
    },
    "data":{
        "hasLocation":false
},
    "getLocation"(){
      const that = this;
      wx.getLocation({
        "success"(res){
          console.log(res);
          that.setData({
            "hasLocation":true,
            "location":formatLocation(res.longitude,res.latitude)
});
        }
});
    },
    "clear"(){
      this.setData({
        "hasLocation":false
});
    }
});

</script>
<style 
 lang="css">
.page-body-info {
  height: 225px ;
}
.page-body-text-small {
  font-size: 12px ;
  color: var(--weui-FG-0) ;
  margin-bottom: 50px ;
}
.page-body-text-location {
  display: flex ;
  font-size: 25px ;
}
.page-body-text-location .onekit-text {
  margin: 5px ;
}
</style>